package BookStore.dao;

import BookStore.model.Admin;

import BookStore.util.UDbUtil;
import BookStore.view.A_Frame;


import javax.swing.*;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class ALoginDao {
    String name_1;
    String pswd_1;

    public ALoginDao(Admin admin) {
        name_1 = admin.getAdminName();
        pswd_1 = admin.getAdminPsw();

    }
    public void ligin_1() throws Exception {
        Connection con_1 = UDbUtil.getCon();
        Statement statement_1 = con_1.createStatement();

        String sql_1 = "select * from admin where name = '"+ name_1 +"' and psw = '"+pswd_1+"'";
        ResultSet resultSet_1 =  statement_1.executeQuery(sql_1);
        if (resultSet_1.next()) {
            new A_Frame().Aframe();
        }else {
            JOptionPane.showMessageDialog(null,"管理员名或密码错误");

        }
    }

}
